﻿Imports System.Object
Imports VSModel
Imports Cls_Common
Imports System.IO
Imports System.Data
Partial Class FrontEnd_Control_YKienKhachHang
    Inherits System.Web.UI.UserControl

#Region "Sub and function"
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then '
            LoadData()
        End If
    End Sub
    Private Sub LoadData()
        Using Data As New VSEntities
            Dim _ParentId As Integer = ConfigurationManager.AppSettings("IdYkienKH_Vi")
            Dim _Lang As Integer = 1
            If Not Session("LanguageId") Is Nothing Then
                _Lang = Session("LanguageId")
            End If
            If _Lang = 2 Then
                lblTitleYKienKhachHang.Text = "Client Testimonials"
                _ParentId = ConfigurationManager.AppSettings("IdYkienKH_En") 'ParentId tieng anh
            Else
                lblTitleYKienKhachHang.Text = "Ý Kiến Khách Hàng"
            End If
            Dim p = (From q In Data.Menus Where q.ParentId = _ParentId And q.LanguageId = _Lang Order By q.Sort).Take(4).ToList
            rptShow.DataSource = p
            rptShow.DataBind()
            ' hplMore.NavigateUrl = MainDomain & "tin-tuc.html"
        End Using
    End Sub
#End Region
#Region "Event for control"
    Protected Sub rptShow_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptShow.ItemDataBound
        '  hplTitle.NavigateUrl = MainDomain & "tin-tuc-chi-tiet/" & h.QueryString & "-" & h.Id.ToString & ".html"
        Dim row = CType(e.Item.DataItem, VSModel.Menu)
        Dim img As Image = CType(e.Item.FindControl("imgImage"), Image)
        Dim lblTitle As Label = CType(e.Item.FindControl("lblTitle"), Label)
        Dim hplImg As HyperLink = CType(e.Item.FindControl("hplImg"), HyperLink)
        Dim lblDescription As Label = CType(e.Item.FindControl("lblDescription"), Label)
        ' = CookedImageURL("80-80", row.Image.ToString)
        'CookedImageURL("109-84", row.ImageLogo.ToString)
        lblDescription.Text = row.Description
        img.ImageUrl = row.ImageLogo
        lblTitle.Text = row.Title
        'hplImg.NavigateUrl = MainDomain & row.QueryString & "-" & row.MenuId.ToString & ".html"
        'hplTitle.NavigateUrl = MainDomain & row.QueryString & "-" & row.MenuId.ToString & ".html"
    End Sub
#End Region
End Class
